# reference scores for all benchmark tasks

REF_MIN_SCORE = {
    'pen-broken-joint-easy' : -12.172796387517222 ,
    'pen-broken-joint-medium' : -12.172796387517222 ,
    'pen-broken-joint-hard' : -12.172796387517222 ,
    'pen-shrink-finger-easy' : -12.172796387517222 ,
    'pen-shrink-finger-medium' : -12.172796387517222 ,
    'pen-shrink-finger-hard' : -12.172796387517222 ,
    'door-broken-joint-easy' : -52.33817104624433 ,
    'door-broken-joint-medium' : -52.33817104624433 ,
    'door-broken-joint-hard' : -52.33817104624433 ,
    'door-shrink-finger-easy' : -52.33817104624433 ,
    'door-shrink-finger-medium' : -52.33817104624433 ,
    'door-shrink-finger-hard' : -52.33817104624433 ,
    'relocate-broken-joint-easy' : -4.439599892829203 ,
    'relocate-broken-joint-medium' : -4.439599892829203 ,
    'relocate-broken-joint-hard' : -4.439599892829203 ,
    'relocate-shrink-finger-easy' : -4.439599892829203 ,
    'relocate-shrink-finger-medium' : -4.439599892829203 ,
    'relocate-shrink-finger-hard' : -4.439599892829203 ,
    'hammer-broken-joint-easy' : -240.92803745715037 ,
    'hammer-broken-joint-medium' : -240.92803745715037 ,
    'hammer-broken-joint-hard' : -240.92803745715037 ,
    'hammer-shrink-finger-easy' : -240.92803745715037 ,
    'hammer-shrink-finger-medium' : -240.92803745715037 ,
    'hammer-shrink-finger-hard' : -240.92803745715037 ,
    'antmaze-small-empty' : 0.0 ,
    'antmaze-small-centerblock' : 0.0 ,
    'antmaze-small-lshape' : 0.0 ,
    'antmaze-small-zshape' : 0.0 ,
    'antmaze-small-reverseu' : 0.0 ,
    'antmaze-small-reversel' : 0.0 ,
    'antmaze-medium-1' : 0.0 ,
    'antmaze-medium-2' : 0.0 ,
    'antmaze-medium-3' : 0.0 ,
    'antmaze-medium-4' : 0.0 ,
    'antmaze-medium-5' : 0.0 ,
    'antmaze-medium-6' : 0.0 ,
    'antmaze-large-1' : 0.0 ,
    'antmaze-large-2' : 0.0 ,
    'antmaze-large-3' : 0.0 ,
    'antmaze-large-4' : 0.0 ,
    'antmaze-large-5' : 0.0 ,
    'antmaze-large-6' : 0.0 ,
    'halfcheetah-friction-0.1' : -280.178953 ,
    'halfcheetah-friction-0.5' : -280.178953 ,
    'halfcheetah-friction-2.0' : -280.178953 ,
    'halfcheetah-friction-5.0' : -280.178953 ,
    'halfcheetah-gravity-0.1' : -280.178953 ,
    'halfcheetah-gravity-0.5' : -280.178953 ,
    'halfcheetah-gravity-2.0' : -280.178953 ,
    'halfcheetah-gravity-5.0' : -280.178953 ,
    'halfcheetah-kinematic-footjnt-easy': -280.178953 ,
    'halfcheetah-kinematic-footjnt-medium': -280.178953 ,
    'halfcheetah-kinematic-footjnt-hard': -280.178953 ,
    'halfcheetah-kinematic-thighjnt-easy': -280.178953 ,
    'halfcheetah-kinematic-thighjnt-medium': -280.178953 ,
    'halfcheetah-kinematic-thighjnt-hard': -280.178953 ,
    'halfcheetah-morph-thigh-easy': -280.178953 ,
    'halfcheetah-morph-thigh-medium': -280.178953 ,
    'halfcheetah-morph-thigh-hard': -280.178953 ,
    'halfcheetah-morph-torso-easy': -280.178953 ,
    'halfcheetah-morph-torso-medium': -280.178953 ,
    'halfcheetah-morph-torso-hard': -280.178953 ,
    'hopper-friction-0.1' : -26.3360015397715 ,
    'hopper-friction-0.5' : -26.3360015397715 ,
    'hopper-friction-2.0' : -26.3360015397715 ,
    'hopper-friction-5.0' : -26.3360015397715 ,
    'hopper-gravity-0.1' : -26.3360015397715 ,
    'hopper-gravity-0.5' : -26.3360015397715 ,
    'hopper-gravity-2.0' : -26.3360015397715 ,
    'hopper-gravity-5.0' : -26.3360015397715 ,
    'hopper-kinematic-footjnt-easy': -26.3360015397715 ,
    'hopper-kinematic-footjnt-medium': -26.3360015397715 ,
    'hopper-kinematic-footjnt-hard': -26.3360015397715 ,
    'hopper-kinematic-legjnt-easy': -26.3360015397715 ,
    'hopper-kinematic-legjnt-medium': -26.3360015397715 ,
    'hopper-kinematic-legjnt-hard': -26.3360015397715 ,
    'hopper-morph-foot-easy': -26.3360015397715 ,
    'hopper-morph-foot-medium': -26.3360015397715 ,
    'hopper-morph-foot-hard': -26.3360015397715 ,
    'hopper-morph-torso-easy': -26.3360015397715 ,
    'hopper-morph-torso-medium': -26.3360015397715 ,
    'hopper-morph-torso-hard': -26.3360015397715 ,
    'walker2d-friction-0.1' : 10.079455055289959 ,
    'walker2d-friction-0.5' : 10.079455055289959 ,
    'walker2d-friction-2.0' : 10.079455055289959 ,
    'walker2d-friction-5.0' : 10.079455055289959 ,
    'walker2d-gravity-0.1' : 10.079455055289959 ,
    'walker2d-gravity-0.5' : 10.079455055289959 ,
    'walker2d-gravity-2.0' : 10.079455055289959 ,
    'walker2d-gravity-5.0' : 10.079455055289959 ,
    'walker2d-kinematic-footjnt-easy': 10.079455055289959 ,
    'walker2d-kinematic-footjnt-medium': 10.079455055289959 ,
    'walker2d-kinematic-footjnt-hard': 10.079455055289959 ,
    'walker2d-kinematic-thighjnt-easy': 10.079455055289959 ,
    'walker2d-kinematic-thighjnt-medium': 10.079455055289959 ,
    'walker2d-kinematic-thighjnt-hard': 10.079455055289959 ,
    'walker2d-morph-leg-easy': 10.079455055289959 ,
    'walker2d-morph-leg-medium': 10.079455055289959 ,
    'walker2d-morph-leg-hard': 10.079455055289959 ,
    'walker2d-morph-torso-easy': 10.079455055289959 ,
    'walker2d-morph-torso-medium': 10.079455055289959 ,
    'walker2d-morph-torso-hard': 10.079455055289959 ,
    'ant-friction-0.1' : -325.6 ,
    'ant-friction-0.5' : -325.6 ,
    'ant-friction-2.0' : -325.6 ,
    'ant-friction-5.0' : -325.6 ,
    'ant-gravity-0.1' : -325.6 ,
    'ant-gravity-0.5' : -325.6 ,
    'ant-gravity-2.0' : -325.6 ,
    'ant-gravity-5.0' : -325.6 ,
    'ant-kinematic-anklejnt-easy': -325.6 ,
    'ant-kinematic-anklejnt-medium': -325.6 ,
    'ant-kinematic-anklejnt-hard': -325.6 ,
    'ant-kinematic-hipjnt-easy': -325.6 ,
    'ant-kinematic-hipjnt-medium': -325.6 ,
    'ant-kinematic-hipjnt-hard': -325.6 ,
    'ant-morph-alllegs-easy': -325.6 ,
    'ant-morph-alllegs-medium': -325.6 ,
    'ant-morph-alllegs-hard': -325.6 ,
    'ant-morph-halflegs-easy': -325.6 ,
    'ant-morph-halflegs-medium': -325.6 ,
    'ant-morph-halflegs-hard': -325.6 ,
}

REF_MAX_SCORE = {
    'pen-broken-joint-easy' : 6408.3837890625 ,
    'pen-broken-joint-medium' : 6408.3837890625 ,
    'pen-broken-joint-hard' : 6408.3837890625 ,
    'pen-shrink-finger-easy' : 6408.3837890625 ,
    'pen-shrink-finger-medium' : 6408.3837890625 ,
    'pen-shrink-finger-hard' : 6408.3837890625 ,
    'door-broken-joint-easy' : 2880.5693087298737 ,
    'door-broken-joint-medium' : 2880.5693087298737 ,
    'door-broken-joint-hard' : 2880.5693087298737 ,
    'door-shrink-finger-easy' : 2880.5693087298737 ,
    'door-shrink-finger-medium' : 2880.5693087298737 ,
    'door-shrink-finger-hard' : 2880.5693087298737 ,
    'relocate-broken-joint-easy' : 4233.877797728884 ,
    'relocate-broken-joint-medium' : 4233.877797728884 ,
    'relocate-broken-joint-hard' : 4233.877797728884 ,
    'relocate-shrink-finger-easy' : 4233.877797728884 ,
    'relocate-shrink-finger-medium' : 4233.877797728884 ,
    'relocate-shrink-finger-hard' : 4233.877797728884 ,
    'hammer-broken-joint-easy' : 12794.134825156867 ,
    'hammer-broken-joint-medium' : 12794.134825156867 ,
    'hammer-broken-joint-hard' : 12794.134825156867 ,
    'hammer-shrink-finger-easy' : 12794.134825156867 ,
    'hammer-shrink-finger-medium' : 12794.134825156867 ,
    'hammer-shrink-finger-hard' : 12794.134825156867 ,
    'antmaze-small-empty' : 1.0 ,
    'antmaze-small-centerblock' : 1.0 ,
    'antmaze-small-lshape' : 1.0 ,
    'antmaze-small-zshape' : 1.0 ,
    'antmaze-small-reverseu' : 1.0 ,
    'antmaze-small-reversel' : 1.0 ,
    'antmaze-medium-1' : 1.0 ,
    'antmaze-medium-2' : 1.0 ,
    'antmaze-medium-3' : 1.0 ,
    'antmaze-medium-4' : 1.0 ,
    'antmaze-medium-5' : 1.0 ,
    'antmaze-medium-6' : 1.0 ,
    'antmaze-large-1' : 1.0 ,
    'antmaze-large-2' : 1.0 ,
    'antmaze-large-3' : 1.0 ,
    'antmaze-large-4' : 1.0 ,
    'antmaze-large-5' : 1.0 ,
    'antmaze-large-6' : 1.0 ,
    'halfcheetah-friction-0.1' : 41696.546875 ,
    'halfcheetah-friction-0.5' : 7357.0712890625 ,
    'halfcheetah-friction-2.0' : 11255.9677734375 ,
    'halfcheetah-friction-5.0' : 10199.3271484375 ,
    'halfcheetah-gravity-0.1' : 2466.85 ,
    'halfcheetah-gravity-0.5' : 9509.15 ,
    'halfcheetah-gravity-2.0' : 9509.15 ,
    'halfcheetah-gravity-5.0' : 3756.24 ,
    'halfcheetah-kinematic-footjnt-easy': 12135.0 ,
    'halfcheetah-kinematic-footjnt-medium': 12135.0 ,
    'halfcheetah-kinematic-footjnt-hard': 12135.0 ,
    'halfcheetah-kinematic-thighjnt-easy': 12135.0 ,
    'halfcheetah-kinematic-thighjnt-medium': 12135.0 ,
    'halfcheetah-kinematic-thighjnt-hard': 12135.0 ,
    'halfcheetah-morph-thigh-easy': 12135.0 ,
    'halfcheetah-morph-thigh-medium': 12135.0 ,
    'halfcheetah-morph-thigh-hard': 12135.0 ,
    'halfcheetah-morph-torso-easy': 12135.0 ,
    'halfcheetah-morph-torso-medium': 12135.0 ,
    'halfcheetah-morph-torso-hard': 12135.0 ,
    'hopper-friction-0.1' : 3234.3 ,
    'hopper-friction-0.5' : 3234.3 ,
    'hopper-friction-2.0' : 3234.3 ,
    'hopper-friction-5.0' : 3234.3 ,
    'hopper-gravity-0.1' : 3234.3 ,
    'hopper-gravity-0.5' : 3234.3 ,
    'hopper-gravity-2.0' : 3234.3 ,
    'hopper-gravity-5.0' : 3234.3 ,
    'hopper-kinematic-footjnt-easy': 3234.3 ,
    'hopper-kinematic-footjnt-medium': 3234.3 ,
    'hopper-kinematic-footjnt-hard': 3234.3 ,
    'hopper-kinematic-legjnt-easy': 3234.3 ,
    'hopper-kinematic-legjnt-medium': 3234.3 ,
    'hopper-kinematic-legjnt-hard': 3234.3 ,
    'hopper-morph-foot-easy': 3234.3 ,
    'hopper-morph-foot-medium': 3234.3 ,
    'hopper-morph-foot-hard': 3234.3 ,
    'hopper-morph-torso-easy': 3234.3 ,
    'hopper-morph-torso-medium': 3234.3 ,
    'hopper-morph-torso-hard': 3234.3 ,
    'walker2d-friction-0.1' : 3360.181 ,
    'walker2d-friction-0.5' : 4229.348 ,
    'walker2d-friction-2.0' : 5180.044 ,
    'walker2d-friction-5.0' : 4988.835 ,
    'walker2d-gravity-0.1' : 2074.904 ,
    'walker2d-gravity-0.5' : 5194.713 ,
    'walker2d-gravity-2.0' : 5056.445 ,
    'walker2d-gravity-5.0' : 3665.385 ,
    'walker2d-kinematic-footjnt-easy': 4592.3 ,
    'walker2d-kinematic-footjnt-medium': 4592.3 ,
    'walker2d-kinematic-footjnt-hard': 4592.3 ,
    'walker2d-kinematic-thighjnt-easy': 4592.3 ,
    'walker2d-kinematic-thighjnt-medium': 4592.3 ,
    'walker2d-kinematic-thighjnt-hard': 4592.3 ,
    'walker2d-morph-leg-easy': 4592.3 ,
    'walker2d-morph-leg-medium': 4592.3 ,
    'walker2d-morph-leg-hard': 4592.3 ,
    'walker2d-morph-torso-easy': 4592.3 ,
    'walker2d-morph-torso-medium': 4592.3 ,
    'walker2d-morph-torso-hard': 4592.3 ,
    'ant-friction-0.1' : 7938.962 ,
    'ant-friction-0.5' : 8301.338 ,
    'ant-friction-2.0' : 5167.376 ,
    'ant-friction-5.0' : 4545.021 ,
    'ant-gravity-0.1' : 2782.098 ,
    'ant-gravity-0.5' : 4317.065 ,
    'ant-gravity-2.0' : 6705.12 ,
    'ant-gravity-5.0' : 6226.89 ,
    'ant-kinematic-anklejnt-easy': 5139.832 ,
    'ant-kinematic-anklejnt-medium': 5139.832 ,
    'ant-kinematic-anklejnt-hard': 5139.832 ,
    'ant-kinematic-hipjnt-easy': 5139.832 ,
    'ant-kinematic-hipjnt-medium': 5139.832 ,
    'ant-kinematic-hipjnt-hard': 5139.832 ,
    'ant-morph-alllegs-easy': 5139.832 ,
    'ant-morph-alllegs-medium': 5139.832 ,
    'ant-morph-alllegs-hard': 5139.832 ,
    'ant-morph-halflegs-easy': 5139.832 ,
    'ant-morph-halflegs-medium': 5139.832 ,
    'ant-morph-halflegs-hard': 5139.832 ,
}

def get_normalized_score(score, env_name):
    ref_min_score = REF_MIN_SCORE[env_name]
    ref_max_score = REF_MAX_SCORE[env_name]
    return (score - ref_min_score) / (ref_max_score - ref_min_score) * 100